package com.athuawei.thread;

public class ThreadJoin {
    public static void main(String[] args) throws InterruptedException {
        float f = 2.1f;
        int i = 1;
        char c = 1;
        Thread rabbitThread = new MyThread("小白兔");
        Thread tigerThread = new MyThread("老虎");

        rabbitThread.start();
        rabbitThread.join();
        tigerThread.start();
    }
}

class MyThread extends Thread {
    private String threadName;

    public MyThread(String threadName) {
        this.threadName = threadName;
    }

    @Override
    public void run() {
        try {
            for (int i = 0; i < 5; i++) {
                System.out.println(threadName + " - " + i);
                Thread.sleep(1000);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
